package PageOR;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;

public class BookAFlight 
{
	WebDriver driver;
	
	@FindBy(how = How.NAME, using = "passFirst0")
	public WebElement txt_FirstName;
	
	@FindBy(how = How.NAME, using = "passLast0")
	public WebElement txt_LastName;
	
	@FindBy(how = How.NAME, using = "creditCard")
	public WebElement lst_CreditCardType;
	
	@FindBy(how = How.NAME, using = "creditnumber")
	public WebElement txt_CreditCardNumber;
	
	@FindBy(how = How.NAME, using = "cc_exp_dt_mn")
	public WebElement lst_CreditCardMonth;
	
	@FindBy(how = How.NAME, using = "cc_exp_dt_yr")
	public WebElement lst_CreditCardYear;
	
	@FindBy(how = How.NAME, using = "cc_frst_name")
	public WebElement txt_CreditCardFirstName;
	
	@FindBy(how = How.NAME, using = "cc_mid_name")
	public WebElement txt_CreditCardMIddleName;
	
	@FindBy(how = How.NAME, using = "cc_last_name")
	public WebElement txt_CreditCardLastName;
	
	
	@FindBy(how = How.NAME, using = "billAddress1")
	public WebElement txt_BillingAddressLine1;
	
	@FindBy(how = How.NAME, using = "billAddress2")
	public WebElement txt_BillingAddressLine2;
	
	@FindBy(how = How.NAME, using = "billCity")
	public WebElement txt_BillingAddressCity;
	
	@FindBy(how = How.NAME, using = "billState")
	public WebElement txt_BillingAddressState;
	
	@FindBy(how = How.NAME, using = "billZip")
	public WebElement txt_BillingAddressZipCode;
	
	@FindBy(how = How.NAME, using = "billCountry")
	public WebElement lst_billCountry;
	
	@FindBy(how = How.NAME, using = "delAddress1")
	public WebElement txt_DelivaryAddressLine1;
	
	@FindBy(how = How.NAME, using = "delAddress2")
	public WebElement txt_DelivaryAddressLine2;
	
	@FindBy(how = How.NAME, using = "delCity")
	public WebElement txt_DelivaryAddressCity;
	
	@FindBy(how = How.NAME, using = "delState")
	public WebElement txt_DelivaryAddressState;
	
	@FindBy(how = How.NAME, using = "delZip")
	public WebElement txt_DelivaryAddressZipCode;
	
	@FindBy(how = How.NAME, using = "delCountry")
	public WebElement lst_DelivaryCountry;
	
	@FindBy(how = How.NAME, using = "buyFlights")
	public WebElement btn_SecurePurchase;
	
	public BookAFlight(WebDriver driver)
	{
		this.driver=driver;
	}
	
	public boolean func_BookFlight(String strFirstName,String strLastName,String strCreditCardType,String intCreditCardNumber,
			String intCrediCardMonth,String intCrediCardYear,String strBillingAddress,String strBillingCity,String strBillingState,
			String strCountry)
	{
		txt_FirstName.sendKeys(strFirstName);
		txt_LastName.sendKeys(strLastName);
		new Select(lst_CreditCardType).selectByVisibleText(String.valueOf(strCreditCardType));
		txt_CreditCardNumber.sendKeys(String.valueOf(intCreditCardNumber));
		new Select(lst_CreditCardMonth).selectByVisibleText(String.valueOf(intCrediCardMonth));
		new Select(lst_CreditCardYear).selectByVisibleText(String.valueOf(intCrediCardYear));
		txt_CreditCardFirstName.sendKeys(strFirstName);
		txt_CreditCardLastName.sendKeys(strLastName);
		txt_BillingAddressLine1.sendKeys(String.valueOf(strBillingAddress));
		txt_BillingAddressCity.sendKeys(String.valueOf(strBillingCity));
		txt_BillingAddressState.sendKeys(String.valueOf(strBillingState));
		new Select(lst_billCountry).selectByVisibleText(String.valueOf(strCountry));
		btn_SecurePurchase.click();
		return false;
	}
	
}
